<?php
/**
 * Copyright (c) 2018,2345
 * 摘    要：Account controller
 * 作    者：林幸亿
 * 修改日期：2018.05.09
 */
namespace App\Controllers;

use \Core\View;
use \App\Models\Account;
use \Library\Session;
use \Library\MysqlDb;

use \Library\RedisDb;
use \Library\RedisSessionHandler;

class TestController extends \Core\Controller
{
    private $model;
    private $view;

    
    public function __construct()
    {
        /*
         *  session_status();
         *  _DISABLED = 0
         *  _NONE = 1
         *  _ACTIVE = 2
         */
    }
    
    function __destruct()
    {
    }
    
     protected function before()
    {
        $this->view = View::renderTpl();
        $this->view->display('Layout/header.tpl.html');
    }
    
    protected function after()
    {
        $this->view->display('Layout/footer.tpl.html');
    }
    
    /**
     * Show the index page
     *
     * @return void
     */
    public function indexAction()
    {
        //$session = Session::getInstance();
        // Set to true if using https
        //$session->start_session('_s', false);
        
        \Predis\Autoloader::register();
        $db = new \Predis\Client();

        //die(var_dump($db));
        
        $sessionHandler = new RedisSessionHandler($db);
        session_set_save_handler($sessionHandler, true);
        
        session_start();
        $_SESSION['hello'] = 'world';
        //die(var_dump($_SESSION));
        //$msg = $session->flash('hello', 'world');
        $this->view->assign('output', 'test');
        $this->view->display('Common/debug.tpl.html');
        //$this->view->display('Common/login.tpl.html');
    }
    
}
